package com.yyt.threadpooldemo.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 异步线程
 *
 * @author: yeyangtao
 * @date: 2020/4/13 18:53
 */
@Component
public class AsyncService {
    @Async(value = "taskExecutor")
    public void demo() throws InterruptedException {
        System.out.println("开始执行1");
        Thread.sleep(2000);
        System.out.println("执行完成1");
        System.out.println("开始执行2");
        Thread.sleep(2000);
        System.out.println("执行完成2");
        System.out.println("开始执行3");
        Thread.sleep(2000);
        System.out.println("执行完成3");
        System.out.println("开始执行4");
        Thread.sleep(2000);
        System.out.println("执行完成4");
    }
}
